<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>chimera.core.threads.ThreadPool</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="chimera-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://chimera.ufsc.br/">Chimera - Observatoty Automation System</a></th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="chimera-module.html">Package&nbsp;chimera</a> ::
        <a href="chimera.core-module.html">Package&nbsp;core</a> ::
        <a href="chimera.core.threads-module.html">Module&nbsp;threads</a> ::
        Class&nbsp;ThreadPool
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="chimera.core.threads.ThreadPool-class.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<!-- ==================== CLASS DESCRIPTION ==================== -->
<h1 class="epydoc">Class ThreadPool</h1><span class="codelink"><a href="chimera.core.threads-pysrc.html#ThreadPool">source&nbsp;code</a></span><br /><br />
Flexible thread pool class.  Creates a pool of threads, then accepts 
  tasks that will be dispatched to the next available thread.<br /><br />

<!-- ==================== INSTANCE METHODS ==================== -->
<a name="section-InstanceMethods"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Instance Methods</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-InstanceMethods"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="__init__"></a><span class="summary-sig-name">__init__</span>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">numThreads</span>=<span class="summary-sig-default">10</span>)</span><br />
      Initialize the thread pool with numThreads workers.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="chimera.core.threads-pysrc.html#ThreadPool.__init__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="chimera.core.threads.ThreadPool-class.html#setThreadCount" class="summary-sig-name">setThreadCount</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">newNumThreads</span>)</span><br />
      External method to set the current pool size.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="chimera.core.threads-pysrc.html#ThreadPool.setThreadCount">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="chimera.core.threads.ThreadPool-class.html#__setThreadCountNolock" class="summary-sig-name">__setThreadCountNolock</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">newNumThreads</span>)</span><br />
      Set the current pool size, spawning or terminating threads if 
      necessary.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="chimera.core.threads-pysrc.html#ThreadPool.__setThreadCountNolock">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="getThreadCount"></a><span class="summary-sig-name">getThreadCount</span>(<span class="summary-sig-arg">self</span>)</span><br />
      Return the number of threads in the pool.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="chimera.core.threads-pysrc.html#ThreadPool.getThreadCount">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="chimera.core.threads.ThreadPool-class.html#queueTask" class="summary-sig-name">queueTask</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">task</span>,
        <span class="summary-sig-arg">args</span>=<span class="summary-sig-default">()</span>,
        <span class="summary-sig-arg">kwargs</span>=<span class="summary-sig-default">{}</span>,
        <span class="summary-sig-arg">taskCallback</span>=<span class="summary-sig-default">None</span>)</span><br />
      Insert a task into the queue.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="chimera.core.threads-pysrc.html#ThreadPool.queueTask">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="chimera.core.threads.ThreadPool-class.html#getNextTask" class="summary-sig-name">getNextTask</a>(<span class="summary-sig-arg">self</span>)</span><br />
      Retrieve the next task from the task queue.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="chimera.core.threads-pysrc.html#ThreadPool.getNextTask">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="joinAll"></a><span class="summary-sig-name">joinAll</span>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">waitForTasks</span>=<span class="summary-sig-default">True</span>,
        <span class="summary-sig-arg">waitForThreads</span>=<span class="summary-sig-default">True</span>)</span><br />
      Clear the task queue and terminate all pooled threads, optionally 
      allowing the tasks and threads to finish.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="chimera.core.threads-pysrc.html#ThreadPool.joinAll">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
</table>
<!-- ==================== METHOD DETAILS ==================== -->
<a name="section-MethodDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Method Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-MethodDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="setThreadCount"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">setThreadCount</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">newNumThreads</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="chimera.core.threads-pysrc.html#ThreadPool.setThreadCount">source&nbsp;code</a></span>&nbsp;
    </td>
  </table>
  
  External method to set the current pool size.  Acquires the resizing 
  lock, then calls the internal version to do real work.
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="__setThreadCountNolock"></a>
<div class="private">
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__setThreadCountNolock</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">newNumThreads</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="chimera.core.threads-pysrc.html#ThreadPool.__setThreadCountNolock">source&nbsp;code</a></span>&nbsp;
    </td>
  </table>
  
  Set the current pool size, spawning or terminating threads if 
  necessary.  Internal use only; assumes the resizing lock is held.
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="queueTask"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">queueTask</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">task</span>,
        <span class="sig-arg">args</span>=<span class="sig-default">()</span>,
        <span class="sig-arg">kwargs</span>=<span class="sig-default">{}</span>,
        <span class="sig-arg">taskCallback</span>=<span class="sig-default">None</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="chimera.core.threads-pysrc.html#ThreadPool.queueTask">source&nbsp;code</a></span>&nbsp;
    </td>
  </table>
  
  Insert a task into the queue.  task must be callable; args and 
  taskCallback can be None.
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="getNextTask"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">getNextTask</span>(<span class="sig-arg">self</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="chimera.core.threads-pysrc.html#ThreadPool.getNextTask">source&nbsp;code</a></span>&nbsp;
    </td>
  </table>
  
  Retrieve the next task from the task queue.  For use only by 
  ThreadPoolThread objects contained in the pool.
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="chimera-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://chimera.ufsc.br/">Chimera - Observatoty Automation System</a></th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    <a href="epydoc-log.html">Generated by Epydoc
    3.0beta1 on Sat Feb  7 18:36:52 2009</a>
    </td>
    <td align="right" class="footer">
      <a href="http://epydoc.sourceforge.net">http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie()
  // -->
</script>
  
</body>
</html>
